package com.TestDemo.Test2;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/21/22:02
 * @Description:
 * @Target:
 */
public class StringToCharsTest {
    public static void main(String[] args) {
        String str = "2dea 12das";
/*
        String[] trim = str.split(" ");
        System.out.print(trim[0]);

*/
        int intern = str.lastIndexOf('a');
        String substring = str.substring(0,intern);
        System.out.println(substring);
        char[] chars = str.toCharArray();  // 直接转为字符数组


        System.out.println();
        for (char aChar : chars) {
            System.out.print(aChar+" ");
        }


    }

}
